package com.yanqu.road.server.cmd.activity.dafuweng;

import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.pb.monopoly.CrossMonopolyProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.cross.battle.DaFuWengDataMgr;
import com.yanqu.road.server.manager.user.CrossUserMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;

@Cmd(code = CrossProtocol.C_CROSS_DA_FU_WENG_GET_UNION_COLLECT, desc = "")
public class CrossDfwCollectCmd extends CrossUnionCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossMonopolyProto.CrossDfwCollectReqMsg msg = CrossMonopolyProto.CrossDfwCollectReqMsg.parseFrom(packet.getBytes());
        int activityId = msg.getActivityId();
        String unionId = msg.getUnionId();
        String reward = msg.getReward();
        Property property = PropertyHelper.parseStringToProperty(reward);
        long msgId = msg.getMsgId();
        UserBaseInfo userBaseInfo = PlayerBasePb.parseBaseUserInfo(msg.getPlayerInfo());
        CrossUserMgr.updateUserBaseInfo(packet.getPlayerId(), userBaseInfo);
        DaFuWengDataMgr.collectGoods(activityId, unionId, property, serverId, packet.getPlayerId(), msgId, groupId);
    }

    @Override
    public void sendData() {

    }
}
